From ec12127c4e11f1ac472a9668d3aa78e44dca0685 Mon Sep 17 00:00:00 2001 From: "iap10@freefall.cl.cam.ac.uk" Date: Sat, 12 Feb 2005 00:50:27 +0000 Subject: [PATCH] bitkeeper revision 1.1189 (420d52d34bmxozCOzbUs5pmo2zfT-w) Subject: [PATCH] xenctx.patch Does this sound interesting? I found it useful to debug looping guests. A gdb stub would be nicer - but this one is lighter weight. -Arun Tool for dumping the cpu context # xenctx 1 0 eip: c01dfeab esp: c1603c98 eax: 00000020 ebx: c0432e10 ecx: 00000ee6 edx: 000001f7 esi: c0432d60 edi: 00000296 ebp: c0432d60 cs: 00000060 ds: 00000068 fs: 00000000 gs: 00000033 Signed-off-by: Arun Sharma Signed-off-by: ian@xensource.com --- .rootkeys | 1 + tools/xentrace/xenctx.c | 84 +++++++++++++++++++++++++++++++++++++++++ xen/arch/x86/dom0_ops.c | 6 +++ 3 files changed, 91 insertions(+) create mode 100644 tools/xentrace/xenctx.c diff --git a/.rootkeys b/.rootkeys index 96b1c00dbf..c990c9d741 100644 --- a/.rootkeys +++ b/.rootkeys @@ -846,6 +846,7 @@ 41d58ba6ijEF6fedqRO5vFu7uCirZg tools/xcs/xcsdump.c 403a3edbrr8RE34gkbR40zep98SXbg tools/xentrace/Makefile 40a107afN60pFdURgBv9KwEzgRl5mQ tools/xentrace/formats +420d52d2_znVbT4JAPIU36vQOme83g tools/xentrace/xenctx.c 4050c413PhhLNAYk3TEwP37i_iLw9Q tools/xentrace/xentrace.8 403a3edbVpV2E_wq1zeEkJ_n4Uu2eg tools/xentrace/xentrace.c 403a3edblCUrzSj0mmKhO5HOPrOrSQ tools/xentrace/xentrace_format diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c new file mode 100644 index 0000000000..4a65d53169 --- /dev/null +++ b/tools/xentrace/xenctx.c @@ -0,0 +1,84 @@ +/****************************************************************************** + * tools/xentrace/xenctx.c + * + * Tool for dumping the cpu context + * + * Copyright (C) 2005 by Intel Corp + * + * Author: Arun Sharma + * Date: February 2005 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xc.h" + +#ifdef __i386__ +void +print_ctx(full_execution_context_t *ctx1) +{ + execution_context_t *ctx = &ctx1->cpu_ctxt; + + printf("eip: %08lx\t", ctx->eip); + printf("esp: %08lx\n", ctx->esp); + + printf("eax: %08lx\t", ctx->eax); + printf("ebx: %08lx\t", ctx->ebx); + printf("ecx: %08lx\t", ctx->ecx); + printf("edx: %08lx\n", ctx->edx); + + printf("esi: %08lx\t", ctx->esi); + printf("edi: %08lx\t", ctx->edi); + printf("ebp: %08lx\n", ctx->ebp); + + printf(" cs: %08lx\t", ctx->cs); + printf(" ds: %08lx\t", ctx->ds); + printf(" fs: %08lx\t", ctx->fs); + printf(" gs: %08lx\n", ctx->gs); + +} +#endif + +void dump_ctx(u32 domid, u32 vcpu) +{ + int ret; + xc_domaininfo_t info; + full_execution_context_t ctx; + + int xc_handle = xc_interface_open(); /* for accessing control interface */ + + ret = xc_domain_getfullinfo(xc_handle, domid, vcpu, &info, &ctx); + if (ret != 0) { + perror("xc_domain_getfullinfo"); + exit(-1); + } + print_ctx(&ctx); + xc_interface_close(xc_handle); +} + +int main(int argc, char **argv) +{ + int vcpu = 0; + + if (argc < 2) { + printf("usage: xenctx \n"); + exit(-1); + } + + if (argc == 3) + vcpu = atoi(argv[2]); + + dump_ctx(atoi(argv[1]), vcpu); + + return 0; +} diff --git a/xen/arch/x86/dom0_ops.c b/xen/arch/x86/dom0_ops.c index ea43287668..9e7ec8c31b 100644 --- a/xen/arch/x86/dom0_ops.c +++ b/xen/arch/x86/dom0_ops.c @@ -348,11 +348,17 @@ void arch_getdomaininfo_ctxt( struct exec_domain *ed, full_execution_context_t *c) { int i; + unsigned long vmx_domain = ed->arch.arch_vmx.flags; + extern void save_vmx_execution_context(execution_context_t *); c->flags = 0; memcpy(&c->cpu_ctxt, &ed->arch.user_ctxt, sizeof(ed->arch.user_ctxt)); + + if (vmx_domain) + save_vmx_execution_context(&c->cpu_ctxt); + if ( test_bit(EDF_DONEFPUINIT, &ed->ed_flags) ) c->flags |= ECF_I387_VALID; if ( KERNEL_MODE(ed, &ed->arch.user_ctxt) ) -- 2.30.2